Free Essay

Treteeeeeee

In:

Submitted By mackstyler
Words 252
Pages 2
MCE 126L
Section 3
Instructor: Dr. Rami Ali
HW 1
Submission date: 15/10/2014
Fall 2014

Q1)
a)

a) #include <stdio.h> b) c) int main() d) { e) f) printf("%s\n","happy birthday\n"); g) h) return(0); i) j) }

Explanation: Since we want to print a string, we must enclose the string within double quotes

b) #include <stdio.h>

int main()
{

printf("%s\n","hello\n");

return(0);

}
Explanation : Since we are supposed to print a string, we should type %s instead of %c which is used with a single character, not a string. Also, Hello should be between double quotes.

C) #include <stdio.h>

int main()
{
char c = 'a'; printf( "%c\n", c);

return(0); }
Explanation: (a) should between single quotes and string s should be string c since we are dealing with a character from the first place.

D)
#include <stdio.h>

int main()
{
printf(" Enter your name\n");

return(0);

}
Explanation: Enter your name should be enclosed with double quotes.

e)

#include <stdio.h>

int main()
{
printf( "%f", 123.456);

return(0);

}
Explanation: We use double quotes when use the function printf.

F)
#include <stdio.h>

int main()
{
printf("%s%s\n","O","K");

return(0);

}

Explanation: the two strings should be enclosed with double quotes.

G)
#include <stdio.h>

int main()
{
int d; scanf("%d", &d); printf("%d", d);

return(0);

}

Explanation: Double quotes should be used.

Q2)

Q3)

Similar Documents