ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
how to convert an char array to decimal array
 Question Submitted By :: Shraddha
I also faced this Question!!     Rank Answer Posted By  
 
  Re: how to convert an char array to decimal array
Answer
# 1
#include<stdio.h>
#include<conio.h>
void main()
{
char a1[50];
int a2[50];
printf("enter the characters :");
gets(a1);
for(int i=0;a1[i]!='\0';i++)
a2[i]=(int)a1[i];     // TYPE CASTING
for(i=0;a1[i]!='\0';i++)
printf("%d",a2[i]);
getch();
}


thank you
 
Is This Answer Correct ?    1 Yes 1 No
Vignesh1988i
 
  Re: how to convert an char array to decimal array
Answer
# 2
#include<stdio.h>
int main()
{
	char str[40],*s;
	char ch,ask;
	do
	{
		s=str;
		printf("Enter the string:");
		fgets(str,40,stdin);
		do
		{
			printf("%d ",*s++);
		}while(*s);
		printf("\nDo u want to enter another string
(y/n):");
		ask=getchar();
		if(ask=='n')
			break;
	}while((ch=getchar())!='n');
	printf("\n");
}
 
Is This Answer Correct ?    1 Yes 0 No
Yogesh
 
 
 
  Re: how to convert an char array to decimal array
Answer
# 3
main()
{
 int a[5];
 char c[5]={'1','2','3','4','5'};
 int i;
 for(i=0;i<5;i++)
   a[i]=c[i]-'0';
 for(i=0;i<5;i++)
   printf("%d ",a[i]);
}
 
Is This Answer Correct ?    0 Yes 0 No
Raj
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
What is the purpose of Scanf Print, getchar, putchar, function?  2
What is the difference b/w main() in C language and main() in C++.  6
write program on arrays GE2
pgm to reverse string using arrays i.e god is love becomes love is god) (assumption:only space is used for seperation of words) no addtional memory used.i.e no temporary arrays can used. Persistent4
Which is not valid in C? 1) class aClass{public:int x;} 2) /* A comment */ 3) char x=12;  5
#include<stdio.h> main() { char s1[]="Ramco"; char s2[]="Systems"; s1=s2; printf("%s",s1); } Find the output CitiGroup4
What are the different pointer models in c?  3
pick out the odd one out of the following a.malloc() b.calloc() c.free() d.realloc() TCS1
identify the in correct expression a.a=b=3=4; b.a=b=c=d=0; float a=int b=3.5; d.int a; float b; a=b=3.5; TCS5
How do you write a program which produces its own source code as its output?  3
Can I pass constant values to functions which accept structure arguments?  2
what does the following code do? fn(int n,int p,int r) { static int a=p; switch(n){ case 4:a+=a*r; case 3:a+=a*r; case 2:a+=a*r; case 1:a+=a*r; } } a.computes simple interest for one year b.computes amount on compound interest for 1 to 4 years c.computes simple interest for four year d.computes compound interst for 1 year TCS4
How to reverse a string using a recursive function, without swapping or using an extra memory? Motorola18
What is the main differences between C and Embedded C?  2
totally how much header files r in c language TCS4
differentiate between const char *a; char *const a; and char const *a; HCL1
int main() { int *p=new int; *p=10; del p; cout<<*p; *p= 60; cout<<*p; } what will be the output & why? TCS4
which one is not preprocessor directive a)#if b)#elif c)#undef d)#pragma Wipro13
can i know the source code for reversing a linked list with out using a temporary variable? Honeywell6
Write a program in c to input a 5 digit number and print it in words.  1
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com