-->

program to convert kilometer to meter

// program to convert kilometer to meter
#include<stdio.h>
#include<conio.h>
void main()
{
float kilometer;
float meter;
printf(“enter value of kilometer\n”);
scanf(“%f”,&kilometer);
meter=kilometer*1000;
printf(“the area is=%f\n”,meter);
getch();
}

input and output programs in c++ (section 1)

Click the particular line to goto that page.
-------------------------------------------------------------

1. program to print hello world(1)

                                                                                solution
2. program to understand endl(2)
                                                                                solution
3. program to understand escape sequence(3)
                                                                                solution
4.program to understand white space(4)
                                                                               solution
5.program to use header file  with double quote(5)
                                                                                solution
6.program to understand input(6)
                                                                                 solution
7.program to know about cin to input data(7)
                                                                                 solution
8.program to understand string input in c++(8)
                                                                                 solution
9.program to print multiple string using single cout(9)
                                                                                 solution
10.program to understand character variable and constant(10)
                                                                                  solution
11.program to understand definition of variables(11)
                                                                                   solution
12.program to print character constatnt(12)
                                                                                   solution
13.program to understand setw() function(13)
                                                                                     solution
14.program to understand library function(14)
                                                                                      solution
15.program to understand type casting (data type conversion)(15)
                                                                                      solution
16. program to understand assignment operator(16)
                                                                                      solution

17.program to understand const identifier(p17)
                                                                                      solution
18.program to understand define directive or symbolic constant(18)
                                                                                       solution
19.program to understand arithmetic remainder operator(19)
                                                                                         solution
20.program to understand unary operator(prefix and postfix)(20)
                                                                                           solution
21. program to generate given table using single cout(21)
                                                                                          solution
22.program to generate following output(22)
                                                                                          solution
23. program to understand relational operator(23)
                                                                                          solution
24.program to understand logical operator(24)
                                                                                           solution
25.program to understand conditional operator(25)
                                                                                            solution
26.program to clear the screen using system(cls)(26)
                                                                                             solution
27.program to add two numbers without using namespace(27)
                                                                                              solution
28.program to print hello world without namespace(28)
                                                                                               solution

WAP to count number of vowels and consonants given in a text.

//WAP to count number of vowels and consonants given in a text.
#include<stdio.h>
include<conio.h>
#include<ctype.h>void main()
{                                                           
char name[30];                                                    
int i,vowel=0,cnst=0;
printf("enter string\n");
gets(name);

for(i=0;name[i]!='\0';i++)
{
if(name[i]==toupper(a)  || name[i]==toupper(e) || name[i]==toupper(i) || name[i]==toupper(o) || name[i]==toupper(u))
{
  vowel++;
}
else
{
  cnst++;
}
}
printf("total vowel present=%d\n",vowel);
printf("total consonant present=%d\n",cnst);
getch();
}
        

WAP to count total number of particular character present in a string.

//WAP to count total number of particular character present in a string.
#include<stdio.h>
include<conio.h>
void main()
{                                                           
char name[30], c;                                                    
int i,count=0;
printf("enter string\n");
gets(name);
printf("enter a character \n");
c=getchar();
for(i=0;name[i]!='\0';i++)
{
if(name[i]==c)
{
  count++;
}
}
printf("total character present=%d\n",count);
getch();
}
        

WAP to know a number /string is Palindrome or not.

// WAP to know a number /string is Palindrome or not.
#include<stdio.h>
include<conio.h>
void main()
{                                                           
char name[30];                                                    
char temp[30];
printf("enter string\n");
gets(name);
strcpy(temp,name);
if((strcmp(strrev(name),temp))==0)
{
  print("it is palindrome\n");
}
else
{
printf("it is not\n");
}
getch();
}
        

WAP to store book's name,price and author's name in a file named 'book.dat' and then read and display on monitor.

//WAP to store book's name,price and author's name in a file named 'book.dat' and then read and display on //monitor.
#include<stdio.h>
include<conio.h>
void main()
{
FILE *k;                                                                    //  pointer for file declaration
char book_name[30],,author[100],choice;                                                    //identifier declaration
int book_price;                                             //       "             "
k=fopen("book.dat","w");
do
{
printf("enter book's name\n");                                       // getting inuts
gets(book_name);
printf("enter book's price\n");
scanf("%d",&book_price);
printf("enter author\n");
scanf("%s",author);

fprintf(k,"%s %d %s",book_name,book_price,author);   //writing data to data file
printf("want to continue y/n\n");
choice=getche();                                                        //getting a character from user  
}while(choice!='n');                                                      // validating the input
printf("writing process completed successfully\n");
fclose(k);                                                                                   //closing data file
printf("now reading the records\n");
k=fopen("book.dat","r");
while((fscanf(k,"%s %d %s",book_name,&book_price,author)!=EOF))//reading data from data file
{
printf("book name=%s , price=%d", and author name=%s",book_name,book_price,author_name); //displaying data
}
fclose(k);
getch();
}

WAp to enter student's name,his/her address and their roll number using struct. Then display them

//WAp to enter student's name,his/her address and their roll number using struct. Then display them
#include<stdio.h>
#include<conio.h>
struct detail
{
int roll;
char name[100];
char address[100];
}var[100];

void main()
{
int i,j,n;
printf("enter total number of records (less or than '100')\n");
scanf("%d",&n);
printf("now enter records of students\n");
for(i=0;i<n;i++)
{
printf("enter student's roll no.\n");
scanf("%d",&var[i].roll);
printf("enter student's name\n");
scanf("%s",var[i].name);
printf("enter student's address\n");
scanf("%s",var[i].address);
}
printf("entered records are=\n");
  for(i=0;i<n;i++)
{
printf("student's roll=%d, name=%s,student's address=%s \n",var[i].roll,var[i].name,var[i].address);
}
getch();
}