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:-
#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:-
[codesyntax lang=”c”]
#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(); }
[/codesyntax]
ScreenShot:-