Programming Fundamentals: Selection and Control Structures(Session I)

Input and Output Statements / Hands On Session I



Hello World 1
Write a program to print “Hello World!”
 
Sample Output:
Hello World!


#include<stdio.h>
int main()
{
  printf("Hello World!\n");
  return 0;
}


                                                         WELCOME ALIENS
You reside in a desert place, One day a space shuttle lands infront of your eyes. Two Aliens  comes out of the space shuttle. They were so friendly and you just want to  Welcome them to our planet. Write a C program to welcome those two aliens to our planet EARTH.

Sample output:
Hello Aliens ! Welcome to our planet Earth.


#include<stdio.h>
int main()
{
 printf("Hello Aliens ! Welcome to our planet Earth.\n");
  return 0;

}


ROBOT
 
Think that you are a scientist and you have invented a Humanoid Robo.You want to introduce your Robo in a public meeting.You need to feed the information that the Robo has to speak in the public meeting.So feed the basic information into the Robo using C program.
NOTE: The basic information includes the name of the Robo, creator, purpose of creation, Memory space of the Robo and its speed.
Input and Output Format:
Input consists of name (char array), creator (char array), purpose (char array), memory space (int), speed (float) and the output format is to display all the details in correct order. Refer sample input and output for further details.
[All text in bold corresponds to input and the rest corresponds to output]
Sample Input and output:
Enter the Name :
Chitti
Enter the Creator Name :
Dr.Vasegran
Enter the Purpose :
militaryservice
Memory Space :
22
Speed :
1.1
My Details :
I am the Robot named Chitti.
I was created by Dr.Vasegran.
I am created for the purpose of militaryservice.

My memory space is around 22Gb and my speed is 1.1Tb.


#include<stdio.h>
int main()
{
  char name[25],creatorname[25],purpose[25];
  int memoryspace=0;
  float speed;
  printf("Enter the Name :\n");
  scanf("%s",name);
  printf("Enter the Creator Name :\n");
  scanf("%s",creatorname);
  printf("Enter the Purpose :\n");
  scanf("%s",purpose);
  printf("Memory Space :\n");
  scanf("%d",&memoryspace);
  printf("Speed :\n");
  scanf("%g",&speed);
  printf("My Details :\n");
  printf("I am the Robot named %s.\n",name);
  printf("I was created by %s.\n",creatorname);
  printf("I am created for the purpose of %s.\n",purpose);
  printf("My memory space is around %dGb and my speed is %gTb.\n",memoryspace,speed);
  return 0;
}


NEWSPAPER REPORT
 
In Japan ,there was a very huge Tsunami. Millions and millions worth buildings and properties were destroyed. Many people lost their lives. Most of them were injured and few were safe. A news reporter arrives to the spot to take the current survey regarding the situation of the people alive , dead and injured. He wanted to publish it in the newspaper and ask the other countries to help the affected people. 
Can you please help him in this noble cause by writing a C program to generate the newspaper report?
INPUT FORMAT:
Input consists of three integers corresponding to the number of people dead , injured and those who are still alive and safe.
OUTPUT FORMAT:
Refer sample input and output for formatting specifications.
 
[All text in bold corresponds to input and the rest corresponds to output]
SAMPLE INPUT AND OUTPUT FORMAT:
Enter the number of people dead:
2000
Enter the number of people injured:
3000
Enter the number of people safe:
10000
TSUNAMI REPORT OF JAPAN
The number of people
1)Dead:2000
2)Injured:3000
3)Safe:10000
Please help the people who are suffering!!!

#include<stdio.h>
int main()
{
 int dead,injured,safe;
  printf("Enter the number of people dead:\n");
  scanf("%d",&dead);
  printf("Enter the number of people injured:\n");
  scanf("%d",&injured);
  printf("Enter the number of people safe:\n");
  scanf("%d",&safe);
  printf("TSUNAMI REPORT OF JAPAN\n");
  printf("The number of people\n");
  printf("1)Dead:%d\n",dead);
  printf("2)Injured:%d\n",injured);
  printf("3)Safe:%d\n",safe);
  printf("Please help the people who are suffering!!!\n");
  return 0;

}
SHARE
    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment

loading...