Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Ca some one please help me with aC code to allow user enter
numbers from 1 to 20 without repeating and prnt the sum of
those numbers
thnx

Answers were Sorted based on User's Feedback



Ca some one please help me with aC code to allow user enter numbers from 1 to 20 without repeating ..

Answer / asadhsheriff

int main()
{
int a[20],i,j,count=0;
memset(a,0,20);
for(;count<=20;)
{
scanf("%d",&j);
if(a[j]==0)
{
count++;
a[j]=j;
}
}
i=20(10)/2;
printf("The sum is %d",i);
}

Is This Answer Correct ?    1 Yes 0 No

Ca some one please help me with aC code to allow user enter numbers from 1 to 20 without repeating ..

Answer / douglas

I so far have nothing

Is This Answer Correct ?    0 Yes 0 No

Ca some one please help me with aC code to allow user enter numbers from 1 to 20 without repeating ..

Answer / kaiss

we will use looping for making this program.

Is This Answer Correct ?    0 Yes 0 No

Ca some one please help me with aC code to allow user enter numbers from 1 to 20 without repeating ..

Answer / sanjay bhosale

/ Duplicate.cpp : main project file.
// Program : To find duplicate no in array by traversing it only once.
#include "stdafx.h"
#include<stdio.h>
#include<malloc.h>

using namespace System;

int main(array<System::String ^> ^args)
{
int *arr;
int val = 0;
int size = 0;
printf(" \n Enter the no of elements in array :");
scanf_s("%d",&size);
arr = (int *)malloc(sizeof(int)*size);
printf("\n Enter elements in the range 1 to %d:",size);
for(int i=0;i<size;i++)
{
scanf_s("%d",&val);
if(val<1 && val>=size)
{
printf("\n enter element again :\t");
i--;
}
else
*(arr+i) = val;
}
int sum = 0;
getchar();
printf("Array is :\n");
for(int i=0;i<size;i++)
{
printf("\t %d",arr[i]);
sum+= arr[i];
}
getchar();
printf("\n sum : %d",sum);
int diff = sum-(size*(size-1)/2.0);
printf(" Duplicate element is :%d\n",diff);
getchar();
return 0;
}


Might this help you........

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

What is bss in c?

0 Answers  


write a C program to print the program itself ?!

16 Answers   TCS,


where do we use volatile keyword?

1 Answers  


What type of function is main ()?

0 Answers  


can anyone proide me reading material on svit00ef27@yahoo.com please thanx in advance

1 Answers   IBM,


what is the Output? int a=4 b=3; printf("%d%d%d%d%d%d",a++,++a,a++,a++,++a,a++); printf("%d%d%d%d%d%d",b--,b--,--b,b--,--b,--b);

10 Answers   IBM,


Why is void main used?

0 Answers  


what is difference between null and nul in c language

2 Answers  


what is the output of the following program? main() { int c[]={2,8,3,4,4,6,7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf("%d",*c); ++q; } for(j=0;j<5;j++) { printf("%d",*p); ++p; } }

4 Answers  


Is exit(status) truly equivalent to returning the same status from main?

0 Answers  


why should i select you?

21 Answers   Wipro,


When you call malloc() to allocate memory for a local pointer, do you have to explicitly free() it?

2 Answers   Aloha Technology,


Categories