C Programming assignment questions, Exercises of C programming

C programming assignment questions

Typology: Exercises

2018/2019

Uploaded on 09/17/2019

Sunitha.P
Sunitha.P 🇮🇳

3 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
18/09/2017
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 mathemacal and logical
problems.
CO2 - Write and implement programs using decision making
statements and looping constructs.
Program outcome mapped : PO1,PO2
Find the output of the following code
1.
#include<stdio.h>
main()
{
int const a = 5;
a++;
prin(“%d”,a);
}
2.
#include<stdio.h>
int main()
{
int a, b = 10;
a = -b--;
prin("a = %d, b = %d", a, b);
return 0;
}
3.
#include <stdio.h>
int main()
{
int chr = 69;
printf("Character having ASCII value 69 is
%c.",chr);
return 0;
}
4.
#include<stdio.h>
int main()
{
int k=1;
printf("%d == 1 is %d\n", k, k==1?1:0);
return 0;
}
5.
#include<stdio.h>
int main()
{
float a=3.15529;
printf("%2.1f\n", a);
return 0;
}
6.
#include<stdio.h>
int main()
{
int a=250;
printf("%1d\n", a);
return 0;
}
7.
What will be the output of the program if value
25 given to scanf()?
#include<stdio.h>
8. #include <stdio.h>
int main()
{
pf3

Partial preview of the text

Download C Programming assignment questions and more Exercises C programming in PDF only on Docsity!

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>

  1. #include <stdio.h> int main() {

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); }