Create a program called dataExercise.c that declares the following variables and
ID: 3630661 • Letter: C
Question
Create a program called dataExercise.c that declares the following variables and displays their values:Declare a string variable with the value "Hello World! I am a string", and display the string using printf with a %s format
Declare a character variable with value 'a', and display the character using printf with a %c format. Then add a second printf that displays the characater with a %d format.
Declare a short int variable with a value set to the maximum value of a short int (the maximum value for whatever machine I happen to use to grade your assignment - so use the correct limits.h constant). Display the value using printf with a %d format.
Declare a double variable with a value set to positive infinity. Display the value using printf with a %f format.
Declare a pointer to the short int variable you created in (3). Display the value stored in the pointer using printf with a %d format.
Display the value of the short int in (3) using the pointer in (5) in a printf statement with a %d format
Explanation / Answer
#include<stdio.h>
#include<conio.h>
main()
{ char str[]="Hello World! I am a string";
printf("%s",str);
char c='a';
printf("%c",a);
short int n= 32767;
printf("%n",&n);
double f=123456;
printf("%f",&f);
short int *p=&n;
printf("%d",*p);
printf("%d",*p);
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.