Answers to Programming in C Third Edition by Stephen G Kochan?
Programming in C Third Edition by Stephen G Kochan is a book about a programming language that consists of cross platform usage as long as you had adhered to the rules of the language!
This language can be combined with other "SDK" header files or basically code sepearated and formatted to isolated header files that consist of "variable declarations", "function declarations" and perform certain matmatical operations for you as you use the functions in a "modular" way and share peacfully.
What is the ASCII value of white space in c language?
int main (void) { printf ("space is %d\n", ' '); return 0; }
Program to find the occurrences of a given character in a string in c plus plus?
#include
#include
size_t count_char (const std::string& s, const char c)
{
size_t count = 0;
size_t offset = 0;
while ((offset = s.find(c, offset)) != s.npos)
{
++count;
++offset;
}
return count;
}
int main()
{
std::string str {"Hello world!"};
std::cout << "String: "" << str << """ << std::endl;
for (auto c : str )
{
size_t count = count_char (str, c);
std::cout << "'" << c << "' occurs " << count << " time" << (count==1?"":"s") << "." << std::endl;
}
}
Example output:
String: "Hello world!"
'H' occurs 1 time.
'e' occurs 1 time.
'l' occurs 3 times.
'l' occurs 3 times.
'o' occurs 2 times.
' ' occurs 1 time.
'w' occurs 1 time.
'o' occurs 2 times.
'r' occurs 1 time.
'l' occurs 3 times.
'd' occurs 1 time.
'!' occurs 1 time.
Write a program to print whether the letter is vowel or not in BASIC?
vowels$ = "aeiou"
CLS
PRINT "PROGRAM: Find if letter is a vowel or not"
INPUT "Type a single alphabet letter: (a-z)/and, then, press Enter key"; aLetter$
PRINT "Letter "; aLetter$;
IF INSTR(vowels$, LCASE$(aLetter$)) THEN PRINT " is a vowel." ELSE PRINT " is NOT a vowel."
END
What are the different types of control units and explain the hardwired control unit with diagram?
Answer: Control unit is a computerized part of the speech processor. Most of the controls, such as program, volume and sensitivity, are located on the control unit.
Write a program to display Identity matrix?
#include <stdio.h> void main() { int a,b,c,i,j; printf("Enter the number of rows for square matrix : "); scanf("%d",&a); for(i=1;i<=a;i++) { for(c=1,j=1;j<=a;j++,c++) { if(c==i) printf("1 "); else printf("0 "); } printf("\n"); } getch(); }
"Mean" usually means "average", so you just add the numbers together, then divide by 8.
Assembly language program to check whether the number is even or odd?
;Program to check whether the value in register is even or odd
.ORIG X3000
AND R2,R1,X0001
BRZ EVEN
LEA R0,DEF ;PRINTS ODD IF VALUE IN REGISTER R2 IS 1
PUTS
HALT
EVEN:
LEA R0,ABC ;PRINTS EVEN IF VALUE IN R2 IS 0
PUTS
HALT
ABC .STRINGZ "EVEN"
DEF .STRINGZ "ODD"
.END
It is ASCII not ASC11.
American Standard Code for Information Interchange
Sales consultant interview questions?
One question may be about talking on the telephone. You may also be asked about how much you like dealing with others.
How do you print highest number in an array in C language?
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
void input(double arr[], const int arr_size);
double max(double arr[], const int arr_size);
int main()
{
const int arr_size = 5;
double arr[arr_size] = {0.0};
input(arr, arr_size);
cout << "Highest number is: " << max(arr, arr_size) << endl;
system("PAUSE");
return 0;
}
void input(double arr[], const int arr_size)
{
cout << "Enter " << arr_size << " elements to find the highest:" << endl;
for (int i = 0; i < arr_size; i++)
{
cout << (i + 1) << " element is: ";
cin >> arr[i];
}
}
double max(double arr[], const int arr_size)
{
double highest_num = arr[0];
for (int i = 0; i < arr_size; i++)
{
if (highest_num < arr[i])
{
highest_num = arr[i];
}
}
return highest_num;
}
What are the impact of object oriented on software industry?
what are the impact object oriented on software industry
Base Conversion program in c language?
#include void main(void) { char base_digits[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; int converted_number[64]; long int number_to_convert; int next_digit, base, index=0; /* get the number and base */ printf("Enter number and desired base: "); scanf("%ld %i", &number_to_convert, &base); /* convert to the indicated base */ while (number_to_convert != 0) { converted_number[index] = number_to_convert % base; number_to_convert = number_to_convert / base; ++index; } /* now print the result in reverse order */ --index; /* back up to last entry in the array */ printf("\n\nConverted Number = "); for( ; index>=0; index--) /* go backward through array */ { printf("%c", base_digits[converted_number[index]]); } printf("\n"); }
/* Write C programs that use both recursive and non recursive functions to perform the following searching operation for a Key value in a given list of integers : i) Linear search */
#include <stdio.h>
#define MAX_LEN 10
void l_search_recursive(int l[],int num,int ele);
void l_search(int l[],int num,int ele);
void read_list(int l[],int num);
void print_list(int l[],int num);
void main()
{
int l[MAX_LEN], num, ele;
int ch;
printf("======================================================");
printf("\n\t\t\tMENU");
printf("\n=====================================================");
printf("\n[1] Linary Search using Recursion method");
printf("\n[2] Linary Search using Non-Recursion method");
printf("\n\nEnter your Choice:");
scanf("%d",&ch);
if(ch<=2 & ch>0) {
printf("Enter the number of elements :");
scanf("%d",&num);
read_list(l,num);
printf("\nElements present in the list are:\n\n");
print_list(l,num);
printf("\n\nElement you want to search:\n\n");
scanf("%d",&ele);
switch(ch) {
case 1:
printf("\n**Recursion method**\n");
l_search_recursive(l,num,ele);
getch();
break;
case 2:
printf("\n**Non-Recursion method**\n");
l_search_nonrecursive(l,num,ele);
getch();
break;
}
}
getch();
}
/*end main*/
/* Non-Recursive method*/
void l_search_nonrecursive(int l[],int num,int ele)
{
int j, f=0;
for(j=0; j<num; j++) if( l[j] ele) {
printf("\nThe element %d is present at position %d in list\n",ele,num);
f=1;
}
else {
if((num==0) && (f==0)) printf("The element %d is not found.",ele);
else l_search(l,num-1,ele);
}
getch();
}
void read_list(int l[],int num) {
int j;
printf("\nEnter the elements:\n");
for(j=0;j<num;j++) scanf("%d",&l[j]);
}
void print_list(int l[],int num) {
int j;
for(j=0;j<num;j++) printf("%d\t",l[j]);
}
(Note: Edited for clarity.)
Wap to sorting the element of the array?
void main()
{
int i,j,temp1,temp2;
int arr[8]={5,3,0,2,12,1,33,2};
int *ptr;
for(i=0;i<7;i++)
{ for(j=0;j<7-i;j++) {
if(*(arr+j)>*(arr+j+1))
{ ptr=arr+j;
temp1=*ptr++;
temp2=*ptr;
*ptr--=temp1;
*ptr=temp2;
clrscr();
for(i=0;i<8;i++)
printf(" %d",arr[i]);
getch(); }
Write a program to store students records in a file?
Polynomial multiplication in link list using c language?
#include
#include
struct polynode
{
float coeff;
int exp;
struct polynode *link;
};
void poly_append(struct polynode **,float,int);
void display_poly(struct polynode *);
void poly_multiply(struct polynode *, struct polynode *, struct polynode **);
void padd(float, int, struct polynode **);
main()
{
struct polynode *first, *second, *mult;
int i,coeff,exp,high;
first = second = mult = NULL;
printf("Enter the highest power of polynomial 1: \n");
scanf("%d",&high);
for(i=high;i>0;i--)
{
printf("Enter value for coeff for X^%d : ",i);
scanf("%d",&coeff);
poly_append(&first, coeff,i);
}
printf("\nEnter the highest power of polynomial 2: \n");
scanf("%d",&high);
for(i=high;i>0;i--)
{
printf("Enter value for coeff for X^%d : ",i);
scanf("%d",&coeff);
poly_append(&second, coeff,i);
}
printf("\n\n");
display_poly(&first);
printf("\n");
display_poly(second);
printf("\n");
for(i=1;i<=79;i++)
printf("-");
poly_multiply(first, second, &mult);
printf("\n");
display_poly(mult);
}
/* adds a term to a polynomial */
poly_append(struct polynode **q, float x, int y)
{
struct polynode *temp;
temp = *q;
/* create a new node if the list is empty */
if(*q NULL ) )
{
r = malloc ( sizeof ( struct polynode ) );
r -> coeff = c;
r -> exp = e;
r -> link = temp -> link;
temp -> link = r;
return;
}
temp = temp -> link; /* go to next node */
}
r -> link = NULL;
temp -> link = r;
}
}
How do you clear a character in screen in c language?
this is a tricky one... press alt + f4 and see if that works.
Write your own printf and scanf functions?
just include #define next to #include
or
/*just follow the pattern below*/ example:
#include
#include
#define pf printf
#define sf scanf
void main
{
int number
pf("Enter a value:");
sf("%i",&number);
getch();
}
Write a c program the extracts and prints the rightmost digit of the integral portion of the float?
#include<stdio.h>
int main (void)
{
float x,y;
int z,w;
printf("enter a number:");
scanf("%6.2f",&x);
y=x/10.0;
z=x-y;
w=z%10;
printf("the rightmost digit is %d\n",w);
return 0;
}//main