LAB 2(OPERATORS AND I/O)
LAB 2
After this lab students will learn use operators and formatted /unformatted input output. No need to write algorithms and draw flowchart.
- WAP to read two numbers from the user and determine the larger number using a conditional operator.
- WAP to calculate the number of memory bytes required for an int,float,double and char type variable .
- WAP to read a string with multiple words(i.e. With space ) using scanf function and display.
- Write a program that uses functions:
- scanf() // use[A-Z] inside scanf
- printf()
- getchar()
- putchar()
- gets()
- puts()
5. Write the output of following program and also explain about each output:
#include<stdio.h>
int main()
{
int n=1234;
char ch='A';
char str[10]="Hello World";
printf("1.n=%-6d\n",n);
printf("2.n=%6d\n",n);
printf("3.ch=%-5c\n",ch);
printf("4.ch=%5c\n",ch);
printf("5.string is:%10s\n",str);
printf("6.string is:%10.8s\n",str);
printf("7.string is:%-10.8s\n",str);
return 0:
}