Draw a flow chart of a program that adds N odd numbers starting from 1. The value of N should be input by the user – IGNOU MCA Assignment 2015 – 16

By | September 11, 2015

BACHELOR OF COMPUTER APPLICATIONS

Course Code : BCS-011
Course Title : Computer Basics and PC Software
Assignment Number : BCA(I)/011/Assignment/ 2015
Maximum Marks : 100
Weightage : 25%

 

Draw a flow chart of a program that adds N odd numbers starting from 1. The value of N should be input by the user.

 

Flowchart:-

FC_Add_Odd_Nos

#include<stdio.h>
void main()
{
int NUM,i,SUM=0;
clrscr();
printf(“\nENTER INTERGER NUMBER : “);
scanf(“%d”,&NUM);
for(i=1;i<NUM*2;i++)
{
if(i%2!=0)
{
SUM=SUM+i;
}
}
printf(“\nTHE SUM OF ODD NOS. TILL %d NO. IS %d”,NUM,SUM);
getch();
}

Code:-

#include<stdio.h>
void main()
{
int NUM,i,SUM=0;
clrscr();
printf("\nENTER INTERGER NUMBER : ");
scanf("%d",&NUM);
for(i=1;i<NUM*2;i++)
{
if(i%2!=0)
{
SUM=SUM+i;
}
}
printf("\nTHE SUM OF ODD NOS. TILL %d NO. IS %d",NUM,SUM);
getch();
}

ScreenShot:-

C_program_Add_Odd_Nos

 

C_program_Add_Odd_Nos_Output