Premium Essay

Icp201 Unit 1 Assignment

Submitted By
Words 522
Pages 3
ASSIGNMENT 1 For this assignment, you will write programs based on operators, selection statements, repetition statements and arrays. Instructions • There are 04 questions in this assignment. • Assignment submitted after due date will not be evaluated. • Upload a pdf version of the document on BlackBoard. • Do not submit the assignment via e-mail. • Write your answer after each question in this document. • Name the document as A1_ICP2015_John_Doe.pdf in case your name is John Doe. [You are required to strictly follow the naming convention.] • Materials copied from the Internet or otherwise will attract penalty as per course policy. Due Date: 5:00 pm, March 22, 2014. Grading Criteria Correct answers will be awarded full points. This assignment …show more content…
CODE: #include <stdio.h> int main() { int a=0,b=0,c=0,sum; printf("Enter three integers : "); scanf("%d",&a); scanf("%d",&b); scanf("%d",&c); if(a==b && a==c) {sum=0;} if(a!=b && a==c) {sum=b;} if(a!=b && a!=c) {sum=(a+b+c);} printf("Sum=%d \n",sum); return 0; …show more content…
Suppose you have been given an array {1,6,3,3,2,3,3,2,4,4,2} where values are getting repeated. Now print the first instance of each numbers (Order of Occurrence) Example: Array1[ ]={1,6,3,3,2,3,3,2,4,4,2} Output = 1,6,3,2,4 CODE: #include<stdio.h> int main() { int size=11,a[]={1,6,3,3,2,3,3,2,4,4,2},i,j; for(i=0;i<size;i++) { for(j=i+1;j<size;j++) { if(a[i]==a[j]) { a[j]=-1; } } if(a[i]!=-1) {printf("%d ,",a[i]);} } return 0; }
4. Create a 6x6 array. Ask user to insert values in only the 6x3 sub array and then just mirror that to other left out space in array. For example look Table 1. User fills 6x3 and other part is left blank out. And then you mirror values and result look like Table 2 Table 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Table 1 2 3 3 2 1 4 5 6 6 5 4 7 8 9 9 8 7 1 0 1 1 1 2 1 2 1 1 1 0 1 3 1 4 1 5 1 5 1 4 1 3 1 6 1 7 1 8 1 8 1 7 1 6
CODE:
#include<stdio.h> void main() { int a[6][6],i,j,rev; int count=1; printf("enter array element : \n"); for(i=0;i<6;i++) { for(j=0;j<3;j++) { //a[i][j]=count; //count++; scanf("%d",&a[i][j]); }

Similar Documents