

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
C programming assignment questions
Typology: Exercises
1 / 3
This page cannot be seen from the preview
Don't miss anything!


Malnad College of Engineering Department of Computer Science and Engineering Assignment - 1
Subject : Computer programming using C (CS105/205) Course Outcome covered : CO1 - Write programs in C to solve mathema�cal and logical problems. CO2 - Write and implement programs using decision making statements and looping constructs.
Program outcome mapped : PO1,PO
Find the output of the following code
#include<stdio.h> main() { int const a = 5; a++; prin�(“%d”,a); }
#include<stdio.h> int main() { int a, b = 10; a = -b--; prin�("a = %d, b = %d", a, b); return 0; }
#include <stdio.h> int main() { int chr = 69; printf("Character having ASCII value 69 is %c.",chr); return 0; }
#include<stdio.h> int main() { int k=1; printf("%d == 1 is %d\n", k, k==1?1:0); return 0; }
#include<stdio.h> int main() { float a=3.15529; printf("%2.1f\n", a); return 0; }
#include<stdio.h> int main() { int a=250; printf("%1d\n", a); return 0; }
What will be the output of the program if value 25 given to scanf()? #include<stdio.h>
int main() { int i; prin�("%d\n", scanf("%d", &i)); return 0; }
int c = 5, no = 10; do { no /= c; } while(c--);
printf ("%d\n", no); return 0; }
9 Predict the output of above program? #include <stdio.h> int main() { int i; if (printf("0")) i = 3; else i = 5; printf("%d", i); return 0; }
10 #include<stdio.h> int main() { int n; for (n = 9; n!=0; n--) printf("n = %d", n--); return 0; } What is the output?
9 #include <stdio.h> int main() { int i = 3; while (i--) { int i = 100; i--; printf("%d ", i); } return 0; }
10 #include <stdio.h> int main() { int x = 3; if (x == 2); x = 0; if (x == 3) x++; else x += 2;
printf("x = %d", x);
return 0; }
What is the output?
#include <stdio.h>
int main() { int integer = 9876; float decimal = 987.6543; printf("4 digit integer right justified to 6 column: %6d\n", integer); printf("4 digit integer right justified to 3 column: %3d\n", integer); printf("Floating point number rounded to 2 digits: %.2f\n",decimal); printf("Floating point number rounded to 0 digits: %.f\n",987.6543); printf("Floating point number in exponential form: %e\n",987.6543); }