Place for novice C programmers to get solution for there programming enigmas
Monday, October 26, 2009
How to enable TATA Photon whiz on Ubuntu 9.04/Fedora 11
For all those who are using TATA Photon whiz (Hauwei -EC121 or others) these is small - "How to for Ubuntu 9.04 Jaunty Jackalope & Fedora 11" ,which by default can't Plug n play (atleast for me on Ubuntu :))even with Network Manager Applet -->Mobile broadband --> Country = India --> Provider -->Tata indicom ( Plug2Surf) -->Uname: internet,Password=internet,Ph =#777 ( As its CDMA).
# Ubuntu 9.04 Photon Whiz set up
1)By default Ubuntu 9.04 doesn't have wvdial ,so you can install it via #Synaptic Package Manager -->search for wvdial
---OR--
Insert original Ubuntu Cd
Go to System->Administration->software sources. add cd as a source and close . It will update itself, Then on terminal type,
sudo apt-get install wvdial .
2) Type lsusb command and see what it gives (for me below was result)
binnishah@google:~$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 002: ID 045e:00a4 Microsoft Corp.
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 005: ID 12d1:1411 Huawei Technologies Co., Ltd. ---------> ( Model #,vendor# & product# to trace for modprobe just in case your OS can't catch it plug n play)
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
3)I have Huawei Mobile connect whose model # is EC121 and vendor = 12d1 & product=1411
next,
modprobe usbserial vendor=0xAAAA product=0xBBBB ,
Where AAAA is 12d1 and BBBB is 1411 in my case.
4)Open terminal and give command ( pl.give these while inserting USB photon drive in lap/Server)
sudo wvdialconf /etc/wvdial.conf ---> (These will detect the modem and install it for internet connection by inserting appropriate modem configuration into /etc/wvdial.conf)
** Pl.dont forget sudo or else you will be trapped into permission issues of /usr/sbin/pppd & chap-secrets & pap-secrets permissions and worse would be wvdial.conf wont get Baud speed rate self detected ,neither exact location of modem would be traced
5) Open wvdial.conf in /etc with :-
sudo vi /etc/wvdial.conf ,it has some entries by default add some new & match it as belows:
[Dialer Defaults]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init3 = AT+CRM=1
Stupid Mode = 1
New PPPD = Yes
Modem Type = USB Modem
Phone = #777
ISDN = 0
Password = internet ---> Your ph number of tata/password
Username = internet --> Your uname /#
Modem = /dev/ttyUSB0
Baud = 9600 -->Baud rate would be decided by 4rth command and written automatically into wvdial.conf script
Now save & exit vi,
6)type sudo wvdial
It may give you something like these:--
binnishah@google:~$ sudo wvdial
--> WvDial: Internet dialer version 1.60
--> Cannot get information for serial port.
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Modem initialized.
--> Sending: ATDT#777
--> Waiting for carrier.
ATDT#777
CONNECT 153600
--> Carrier detected. Starting PPP immediately.
--> Starting pppd at Sun Oct 18 17:47:48 2009
--> Pid of pppd: 13130
--> Using interface ppp0
--> local IP address 121.245.189.171
--> remote IP address 172.23.119.14
--> primary DNS address 202.54.29.5
--> secondary DNS address 202.54.10.2
^CCaught signal 2: Attempting to exit gracefully...
--> Terminating on signal 15
--> Connect time 5.1 minutes.
--> Disconnecting at Sun Oct 18 17:52:50 2009
7)Command tail -f /var/log/messages --> Just immediately aft.connection gives following:
binnishah@google:~$ tail -f /var/log/messages
Oct 18 17:47:48 google pppd[13130]: Warning - ***
Oct 18 17:47:49 google pppd[13130]: CHAP authentication succeeded
Oct 18 17:47:49 google pppd[13130]: CHAP authentication succeeded
Oct 18 17:47:49 google pppd[13130]: local IP address 121.245.189.171
Oct 18 17:47:49 google pppd[13130]: remote IP address 172.23.119.14
Oct 18 17:47:49 google pppd[13130]: primary DNS address 202.54.29.5
Oct 18 17:47:49 google pppd[13130]: secondary DNS address 202.54.10.2
Oct 18 17:52:50 google pppd[13130]: Terminating on signal 15
Oct 18 17:52:50 google pppd[13130]: Connect time 5.1 minutes.
Oct 18 17:52:50 google pppd[13130]: Sent 158772 bytes, received 741237 bytes.
8)If you dont want to fall in hassles of pwd ( I wouldn't recommend to do so ,though)
sudo vi /etc/sudoers
# User privilege specification
username machine_name = NOPASSWD: /usr/bin/wvdial
So next time when you give wvdial you dont need to type in password
*For Fedora-11 - TATA Photon Whiz :- ==========================
It came to me as surprise that Fed-11 took it in plug n play ie:- just some tweak with Network manager applet and I was sorted out with live n kicking
tata photon whiz USB Mobile broadband
1)Open Network manager applet
2)In that,there's option of --> Mobile Broadband -->Add ( By default you will have Huawei Technologies or your preferable qualcom or whatever) -->Select it -->Forward -->Country - India -->Forward --> Select Tata Indicom(Plug2Surf) if you have photon whiz -->Forward ->Commit changes by pressing apply
3)In Popup of Editing tata Indicom
Add your username & password
and simply press apply
4)Left click Network manager applet and you will have option of Tata Plug2surf ,select it and you are all set
Hope that helps !!!
*Image courtesy
Thursday, October 8, 2009
Determine Grade of steel
*1)Hardness must be greater than 50
*2)Carbon content must be less than 0.7
*3)Tensile strength must be greater than 5600
*
*The grades are as follows:
*
*Grade is 10 if all three conditions are met
*Grade is 9 if condition 1 & 2 are met
*Grade is 8 if condition 2 & 3 are met
*Grade is 7 if condition 1 & 3 are met
*Grade is 6 if only one condition is met
*Grade is 5 if none of the conditions are met
*
*Write a program which will require the user to give values of hardness,carbon content and tensile
*strength of the steel under consideration and output the grade of the steel*/
# Solution code :
==========
#include <stdio.h>int main(void)
{
int hard,ts; // hard = hardness ; ts = tensile strength
float cc; //cc -- Carbon content
printf("\nEnter hardness of steel: ");
scanf("%d",&hard);
printf("\nEnter Carbon content of steel : ");
scanf("%f",&cc);
printf("\nEnter Tensile strenght of steel : ");
scanf("%d",&ts);
if ( (hard > 50) && (cc < 0.7) && (ts > 5600))
printf("Steel is of 10th Grade");
else if ( (hard > 50) && (cc < 0.7))
printf("Steel is of 9th Grade");
else if ( (cc < 0.7) && (ts > 5600 ))
printf("Steel is of 8th Grade");
else if (( hard > 50) && (ts > 5600 ))
printf("Steel is of 7th Grade");
else if ( (hard > 50) || (cc < 0.7) || (ts > 5600))
printf("Steel is of 6th Grade");
else
printf("Steel is of 5th Grade");
return 0;
}
Determine if eligible for premium & Policy
Determine character input if its Capital,small,decimal or special character
/*Any character is entered through the keyboard ,write a program to determine whether the character entered is a capital letter,a small case letter,a digit or a special symbol
Following is Range of Ascii values for various characters:-
Characters Ascii Values
A-Z 65-90
a-z 97-122
0-9 48-57
Special symbols 0-47,58-64,91-96,123-127 */
#1 Solution ( With Value of ASCII characters as integer as input) :-
========================================
#include <stdio.h>
int main(void)
{
int i;
printf("Enter a character to determine its type : ");
scanf("%d",&i);
if ( (i <= 90) && (i >= 65))
printf("\nIts %c whose value is %d ,which belongs to A-Z character type",i,i);
else if ( i <= 122 && i >= 97 )
printf("\nIts %c whose value is %d,which belongs to a-z character type",i,i);
else if ( i <= 57 && i >= 48 )
printf("\nIts %c whose value is %d,which belongs to 0-9 character type",i,i);
else if (( i <= 47 && i >= 0) || ( i <= 64 && i >= 58) || ( i >= 91 && i <= 96) || ( i <= 127 && i >= 123))
printf("\nIts %c whose value is %d,which belongs to specific symbols",i,i);
return 0;
}
#2 Solution ( With ASCII Characters as input ) :-
==============================
#include <stdio.h>
int main(void)
{
char i;
printf("Enter a character to determine its type :");
scanf("%c",&i);
if (( i <= 'Z') && (i >= 'A'))
printf("\nIts %c whose value is %d ,which belongs to A-Z character type",i,i);
else if (( i >= 'a') && (i <= 'z' ))
printf("\nIts %c whose value is %d,which belongs to a-z character type",i,i);
else if ( (i >= '0') && (i <= '9'))
printf("\nIts %c whose value is %d,which belongs to 0-9 character type",i,i);
else
printf("\nIts %c whose value is %d,which belongs to *special symbols*",i,i);
return 0;
}
Wednesday, April 15, 2009
Calculate gross salary
salary and DA = 90% of basic salary. If his salary is either equal to
or above Rs. 1500, then HRA = Rs. 500 and DA = 98% of basic
salary. If the employee's salary is input through the keyboard write
a program to find his gross salary.*/
Solution Code:-
=========
#include <stdio.h>
int main(void)
{
int bs;
float hra,da,gross;
printf("Enter Basic Salary : ");
scanf("%d",&bs);
if ( bs < 1500 )
{
hra = bs * 10 / 100;
da = bs * 90 /100;
}
else
{
hra = 500 ;
da = bs * 98 /100;
}
gross = hra + da + bs ;
printf("\n Your gross salary is %f",gross);
return 0;
}
Tuesday, April 14, 2009
Print a five digit number by adding one to each of its digits
program to print a new number by adding one to each of its
digits. For example if the number that is input is 12391 then
the output should be displayed as 23402.*/
Solution Code :-
=========
#include <stdio.h>
int main(void)
{
int i,temp = 0;
printf("Enter a +ve 5 digit number :");
scanf("%d",&i);
if (( i <= 99999 ) && ( i > 9999 ))
{
printf(" %d",(i/10000) + 1);
printf(" %d",((( i/100) % 100)/10) + 1);
printf(" %d",(( i/100) % 10 ) + 1);
printf(" %d",((i % 100) / 10) + 1 );
printf(" %d",(i % 10) + 1);
}
else
printf("\n Pl.enter +ve five digit number");
return 0;
}
Monday, April 13, 2009
Calculate price of single item
on them is input through the keyboard, write a program to
find the cost price of one item.*/
/*Here the query maker ,I suppose seeks for groce price rate of one item ,as groce profit & groce selling price is sought out
sin => single item groce price ; procin => profit on single item ;con => conjugal price (profit + single item price)
*/
Solution Code :-
==========
#include <stdio.h>
int main(void)
{
int price,profit,sin,prosin,con;
printf("Enter price of 15 items : ");
scanf("%d",&price);
printf("\nEnter profit made on 15 items : ");
scanf("%d",&profit);
sin = price / 15 ;
prosin = (profit / 15) - sin;
con = sin + prosin ;
printf("\nSingle item cost is %d",sin);
printf("\nSingle item profit is %d",prosin);
printf("\nSingle item cost price is %d",con);
return 0;
}
Sunday, April 12, 2009
Find total number of currency notes of each 10,50,100 denominations
100. If the amount to be withdrawn is input through the
keyboard in hundreds, find the total number of currency notes
of each denomination the cashier will have to give to the
withdrawer.*/
Solution Code:-
=========
#include <stdio.h>
int main(void)
{
int amt;
printf("Enter the amount to withdraw : ");
scanf("%d",&amt);
printf("\nNotes of 100 required are %d", amt/100);
printf("\nWhile Notes of 50 required are %d", ((amt % 100)/50));
printf("\nAnd notes of 10 required are %d",((amt % 100)% 50)/10);
return 0;
}
Percentage of Literate & Illiterate along with men & women in town
total literacy is 48. If total percentage of literate men is 35 of
the total population, write a program to find the total number
of illiterate men and women if the population of the town is
80,000*/
Solution Code:-
===========
/*popmen = population of men,popwo = population of women ,literate women = ilwo,ilmen = ill-literate men,limen = literate men,liwo = literate women,li= literate men*/
#include <stdio.h>
int main(void)
{
int popmen,popwo,ilmen,ilwo,li,limen,liwo,total;
popmen = (80000 * 52)/100;
printf("\nTotal population of Men in town is %d out of 80000",popmen);
popwo = (80000 - popmen);
printf("\nTotal population of women in town is %d out of 80000",popwo);
li = ( 80000 * 48)/100;
printf("\nTotal literate population in town is %d",li);
limen = ( popmen * 35 )/100;
printf("\nTotal amount of literate Men are %d",limen);
ilmen = popmen - limen;
printf("\nTotal amount of Ill-literate Men are %d",ilmen);
liwo = li - limen ;
printf("\nTotal amount of Literate women is %d",liwo);
ilwo = popwo - liwo ;
printf("\n Total amount of Ill-literate women is %d",ilwo);
return 0;
}
Saturday, April 11, 2009
Calculate percentage of 5 subjects & display Divison resp.
Percentage above or equal to 60 - First division
Per btw 50 and 59 - Second div
per btw 40 and 49-Third div
per less than 40 - Fail */
Solution Code:
=========
#include <stdio.h>
int main(void)
{
int m1,m2,m3,m4,m5,sum,per;
printf("Enter marks for Math : ");
scanf("%d",&m1);
printf("\nEnter marks for Chemistry : ");
scanf("%d",&m2);
printf("\nEnter marks for Biology : ");
scanf("%d",&m3);
printf("\nEnter marks for Physics : ");
scanf("%d",&m4);
printf("\nEnter marks for English : ");
scanf("%d",&m5);
sum = (m1 + m2 + m3 + m4 + m5);
per = (sum * 100 / 500);
printf("\nYou got %d percentage",per);
if ( per >= 60 )
printf("\nFirst Division");
else if (( per <= 59) && ( per >= 50 ))
printf("\nSecond Divison");
else if (( per <= 49 ) && ( per >= 40 ))
printf("\nThird Divison");
else
printf("\nSorry you Failed");
return 0;
}
2nd Solution Code:-
===========
#include
int main(void)
{
int m1,m2,m3,m4,m5,sum,per;
printf("Enter marks for Math : ");
scanf("%d",&m1);
printf("\nEnter marks for Chemistry : ");
scanf("%d",&m2);
printf("\nEnter marks for Biology : ");
scanf("%d",&m3);
printf("\nEnter marks for Physics : ");
scanf("%d",&m4);
printf("\nEnter marks for English : ");
scanf("%d",&m5);
sum = (m1 + m2 + m3 + m4 + m5);
per = (sum * 100 / 500);
printf("\nYou got %d percentage",per);
if ( per >= 60 )
printf("\nFirst Division");
else
{
if ( per >= 50 )
printf("\nSecond Division");
else
{
if ( per >= 40 )
printf("\nThird Division");
else
printf("\nFail");
}
}
return 0;
}
Example of compound statement & nested if
*Solution Code:-
===========
#include <stdio.h>
int mod(int i);
int main(void)
{
int i;
printf("Enter an Even number less than 20 : ");
scanf("%d",&i);
if ( i < 20)
{
if ( mod(i))
printf("Oops you entered Odd number %d",i);
else if ( i <= 0 )
printf("Oops you entered number less than or equal to 0 %d",i);
}
else
printf("You entered a number greater than 20");
return 0;
}
int mod(int i)
{
return ( i % 2 );
}
Plays a one-time guessing game with user.User enters a number which is compared with target
Solution Code:-
=========
#include <stdio.h>
#define TARGET 17
int test(int i,int target);
int main(void)
{
int i;
printf("Enter target number : ");
scanf("%d",&i);
test( i,TARGET);
return 0;
}
void test(int i,int target)
{
if ( i > target)
printf("\nTarget number is smaller than %d,try again",i);
else if ( i < target)
printf("\nTarget number is greater than %d,try again",i);
else if ( i == target )
printf("\nFinally you could make it");
}
Detect if number is odd or even by function call
Solution Code:
=========
#include <stdio.h>
int odd(int i);
int main(void)
{
int i;
printf("Enter a decimal integer : ");
scanf("%d",&i);
if (odd(i))
printf("\n%d is Odd number",i);
else
printf("\n%d is Even number",i);
return 0;
}
int odd(int i)
{
return ( i % 2 );
}
A decimal integer is input and added to constant while displaying the sum message is issued
Solution code:-
========
#include <stdio.h>
#define CONSTANT 7
int sum(int num,int constant);
int main(void)
{
int i,add;
printf("Enter a decimal integer : ");
scanf("%d",&i);
add = sum(i,CONSTANT);
if ( add < 20 )
printf("\nAmount %d is less than 20",add);
return 0;
}
int sum(int num,int constant)
{
return (num + constant);
}
Tuesday, March 31, 2009
Calculate sum of digits of five digit +ve number
#include <stdio.h>
int main(void)
{
int num,temp = 0 ,a;
printf("Enter a +ve 5 digit number : ");
scanf("%d",&num);
if (( num <= 99999) && ( num > 0 ))
{
printf("The number you entered is %d ",num);
a = (num / 10000);
temp = a;
a = (num % 10000)/1000;
temp = temp + a;
a = ((num % 10000) % 1000) / 100 ;
temp = temp + a;
a = (((num % 10000) % 1000) % 100) / 10 ;
temp = temp + a;
a = (((num % 10000) % 1000) % 100) % 10;
temp = temp + a;
printf("\nSum of all five digits is %d",temp);
}
else
printf("\nOops not valid figure pl.try again");
return 0;
}
Monday, March 30, 2009
Write an Insurance program with & without && ||
- if the driver is married
- if the driver is unmarried,male & above 30 years of age
-if the driver is unmarried and female & above 25 years of age
In all other cases the driver isnt insured.If marital status ,sex & age of the driver is input ,write a prg to determine whether the driver is to be insured or not */
#include <stdio.h>
int main(void)
{
int age;
char sex,ms; //ms = marital status
printf("Are you married (Y=yes) & (n=no) :");
scanf("%c",&ms);
if ( ms == 'Y')
printf("You are qualified as you are married");
else
{
printf("Enter your sex(M/F)");
scanf(" %c",&sex);
if ( sex == 'M')
{
printf("Enter your age : ");
scanf("%d",&age);
if ( age > 30)
printf("You are qualified for Insurance");
else
printf("Sorry Mr.you are not qualified");
}
else
{
printf("Enter your age : ");
scanf("%d",&age);
if ( age > 25 )
printf("You are qualified for Insurance lady !!!");
else
printf("Sorry gal you are not qualified for Insurance");
}
}
return 0;
}
*Second Method using && ||
============================
#include <stdio.h>
int main(void)
{
int age;
char ms,sex; // ms is marital status
printf("Enter your Age,Sex(M/F),Marital Status (Y/N):");
scanf("%d %c %c",&age,&sex,&ms);
if (( ms == 'Y') || ( ms == 'N') && ( sex == 'M') && ( age > 30) || ( ms == 'N') && ( sex == 'F') && ( age > 25))
printf("You are eligible for Insurance");
else
printf("Sorry no Insurance for you");
return 0;
}
Calculate sum of first and fourth(last) digit of four digit number
#include <stdio.h>
int main(void)
{
int num,temp = 0,a ;
printf("Enter a Four digit +ve number : ");
scanf("%d",&num);
if (( num <= 9999) && ( num > 0 ))
{
printf("\nYou entered %d Number ",num);
a = num / 1000;
printf("\n First digit is %d",a);
temp = a ;
a = num % 10;
printf("\n Fourth digit is %d",a );
temp = temp + a;
printf("\nSum of 1st & fourth digit is %d",temp);
}
else
printf("Pl. enter valid 4 digit +ve number");
return 0;
}
Write a program to reverse 5 digit number
Solution Code:-
=========
#include <stdio.h>
int main(void)
{
int num;
printf("Enter a 5 digit +ve number : ");
scanf("%d",&num);
if (( num < 99999 ) && (num > 0 ))
{
printf("The number you entered is %d ",num);
printf("\nAlternate number is %d",num%10);
printf(" %d",((num/10) % 10));
printf(" %d",(((num/10) / 10) % 10));
printf(" %d",((((num/10) / 10) / 10) % 10));
printf(" %d",( num / 10000));
}
else
printf("Pl.enter valid +ve 5 digit number...");
return 0;
}
How to add/increase speed dials in Opera in Linux
Nonetheless Open terminal & at command prompt type :-
1) vi /root/.opera/speeddial.ini
2)Add following lines :- (preferably at bottom)
[size]
Rows=3
Columns=5
3)Press Esc & save it (:w) & quit (q)
4)Restart Opera you will get new 15 speed-dials
Depending on your needs you can manipulate rows & columns with some R&D
Sunday, March 29, 2009
Write a program to add two fractions
/*Write a prg that adds two fractions.Your ouput need not be in terms*/
#include
int main(void)
{
int n1,n2,b1,b2,res1,res2;
printf("First Fraction \n");
printf("Enter the numerator : ");
scanf("%d",&n1);
printf("\nEnter the denominator : ");
scanf("%d",&n2);
printf("Second Fraction \n");
printf("Enter the numerator : ");
scanf("%d",&b1);
printf("\nEnter the denominator : ");
scanf("%d",&b2);
res1 = ((n1*b2) + (b1*n2));
res2 = (n2*b2);
printf("\nResult of two fraction %d/%d + %d/%d = %d/%d",n1,n2,b1,b2,res1,res2);
return 0;
}
Calculate temperature in Celcius from Fahrenheit
#include
float temp(float fah); //function temp calculates input fahrenheit to Celsius fah is formal parameter
int main(void)
{
float far; // here far is actual parameter whose value is stored in fah formal parameter ,so far => fah
printf("Enter temperature in Fahrenheit : ");
scanf("%f",&far);
printf("\nTemperature in Celcius is %f",temp(far));
return 0;
}
float temp(float fah)
{
return ( 5 * ( fah - 32))/9;
}
Calculate prices of oranges
/*Problem:- A grocery store is selling oranges with price of
1 orange = 9 cent while if its 1 dozen then one dollar.Now write a function
that prompts end user to enter number of oranges ,accepts input of an integer
value and outputs total price of oranges in dollar & cents both,you can have just one parameter in
function/s you declare */
#include
#define PRICE 9 //actual parameter
int doz(int no); //no is formal parameter
int cents(int no); //same no is formal parameter
int main(void)
{
int n ; //n = no here n is actual parameters which is # of oranges
printf("Enter number of oranges to buy :- ");
scanf("%d",&n);
printf("\nPrice of %d oranges is %d Dollar",n,doz(n));
printf(" and %d cents\n",cents(n));
return 0;
}
int doz(int no)
{
return (( no / 12) * 1);
}
int cents(int no)
{
return ((no % 12) * PRICE);
}
Note:- Problem is from book "C by discovery" - Foster & Foster
Friday, March 27, 2009
How to Enable ATI Radeon 3200 card with fglrx on Fedora-10
For novices/myriads in flux here's a detailed how to & problem I faced & how I got rid with it.
Question:- After freshly installing Fedora-10 my PC works fine for few minutes and then freezes up badly that I need to reboot or shutdown and then once again same things are redundant
Ans : You need to install either fglrx or any Opensource driver for your card
Try these :-
** sudo yum install system-config-display ( The moment I installed these rpm package F10 stopped freezing to death but here it takes general Opensource drivers for your card instead we want to use fglrx which allows us to use 3d effects of ATI along with compiz-fusion,so all these below heck we are doing)
Question 2:- How to install & enable fglrx drivers & compiz-fusion ?
1)Check if your card is supported by these ATI driver
2)Update system & Kernel with :-
Code : su -c "yum update"
OR
Code : sudo yum update
3)install the F10 rpmfusion driver
Code:
su -
rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm
yum install kmod-fglrx xorg-x11-drv-fglrx xorg-x11-drv-fglrx-libs.i386
4) Backup Old initrd
su
mv /boot/initrd-`uname -r`.img /boot/initrd-`uname -r`.img.backup
Remake initrd for the kernel (So the radeon module is not force loaded)
su -
mkinitrd -v /boot/initrd-`uname -r`.img `uname -r`
5) Edit grub.conf
su
gedit /boot/grub/grub.conf
Optional (in case libdrm change breaks things due to relationship with KMS):
add "nomodeset" to end of kernel arguments
6. Reboot
due to the akmod, it is *absolutely necessary* to reboot after the install, otherwise the kernel module won't be compiled.
7. Optional install compiz-fusion.
8.How to upgrade libdrm if previously downgraded .
su
rm -f /etc/yum.repos.d/rpmfusion-nonfree-updates-9.repo
rm -f /etc/yum.repos.d/fedora9.repo
sed -i -e 's|^exclude.*||' /etc/yum.repos.d/fedora*
yum clean all
yum update libdrm
1)After reboot on CLE type :-
Code :
sudo aticonfig -v --initial -f (These will do initial /first time setup of fglrx on ATI card) // mindwell dont forget to be super user or else things wont work
2)Then verify if fglrx is enabled or not with :-
Code:-
fglrx-config-display enable
To Restart fglrx :- sudo service fglrx restart
3)For single head you may go for :- aticonfig --initial --input=/etc/X11/xorg.conf
4)For dual head you may go on for:- aticonfig --initial=dual-head --screen-layout=above
This command will generate a dual head configuration
file with the second screen located above the first
screen.
5) Setting up modes for primary display.
aticonfig --resolution=0,1600x1200,1280x1024,1024x768
6) Force primary CRT on and TV-out off.
aticonfig --force-monitor=crt1,notv
7) Change tv geometry
aticonfig --tv-geometry=85x90+10-10
This will set tv to 85% width (where 100% ==
overscan) 90% height and shift 10 pixels right of centre
and 10 pixels down of centre
**Troubleshooting :-
1)sudo aticonfig --initial=check
Identifies if the fglrx driver is present in configuration file.
Output should be :-
[binnishah@redhat ~]$ aticonfig --initial=check
Check: Found fglrx section.
2)Try glxinfo -->
Output should be :-
[binnishah@redhat ~]$ glxinfo
name of display: :4.0
display: :4 screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.2
server glx extensions:
GLX_ARB_multisample, GLX_EXT_import_context, GLX_EXT_texture_from_pixmap,
GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_OML_swap_method,
GLX_SGIS_multisample, GLX_SGIX_fbconfig, GLX_SGIX_visual_select_group
client glx vendor string: SGI
client glx version string: 1.4
client glx extensions:
GLX_ARB_create_context, GLX_ARB_get_proc_address, GLX_ARB_multisample,
GLX_EXT_import_context, GLX_EXT_visual_info, GLX_EXT_visual_rating,
GLX_MESA_allocate_memory, GLX_MESA_swap_control,
GLX_MESA_swap_frame_usage, GLX_NV_swap_group, GLX_OML_swap_method,
GLX_OML_sync_control, GLX_SGI_make_current_read, GLX_SGI_swap_control,
GLX_SGI_video_sync, GLX_SGIS_multisample, GLX_SGIX_fbconfig,
GLX_SGIX_pbuffer, GLX_SGIX_swap_barrier, GLX_SGIX_swap_group,
GLX_SGIX_visual_select_group, GLX_EXT_texture_from_pixmap
GLX version: 1.2
GLX extensions:
GLX_ARB_create_context, GLX_ARB_get_proc_address, GLX_ARB_multisample,
GLX_EXT_import_context, GLX_EXT_visual_info, GLX_EXT_visual_rating,
GLX_MESA_swap_control, GLX_NV_swap_group, GLX_OML_swap_method,
GLX_SGI_video_sync, GLX_SGIS_multisample, GLX_SGIX_fbconfig,
GLX_SGIX_swap_barrier, GLX_SGIX_swap_group, GLX_SGIX_visual_select_group
OpenGL vendor string: ATI Technologies Inc.
OpenGL renderer string: ATI Radeon HD 3200 Graphics
OpenGL version string: 2.1.8494 Release
OpenGL shading language version string: 1.20
OpenGL extensions:
GL_AMD_performance_monitor, GL_ARB_color_buffer_float,
GL_ARB_depth_buffer_float, GL_ARB_depth_texture, GL_ARB_draw_buffers,
GL_ARB_draw_instanced, GL_ARB_fragment_program,
GL_ARB_fragment_program_shadow, GL_ARB_fragment_shader,
GL_ARB_framebuffer_object, GL_ARB_framebuffer_sRGB,
GL_ARB_half_float_pixel, GL_ARB_half_float_vertex,
GL_ARB_instanced_arrays, GL_ARB_map_buffer_range, GL_ARB_multisample,
GL_ARB_multitexture, GL_ARB_occlusion_query, GL_ARB_pixel_buffer_object,
GL_ARB_point_parameters, GL_ARB_point_sprite, GL_ARB_shader_objects,
GL_ARB_shader_texture_lod, GL_ARB_shading_language_100, GL_ARB_shadow,
GL_ARB_shadow_ambient, GL_ARB_texture_border_clamp,
GL_ARB_texture_compression, GL_ARB_texture_compression_rgtc,
GL_ARB_texture_cube_map, GL_ARB_texture_env_add,
GL_ARB_texture_env_combine, GL_ARB_texture_env_crossbar,
GL_ARB_texture_env_dot3, GL_ARB_texture_float,
GL_ARB_texture_mirrored_repeat, GL_ARB_texture_non_power_of_two,
GL_ARB_texture_rectangle, GL_ARB_texture_rg, GL_ARB_transpose_matrix,
GL_ARB_vertex_array_object, GL_ARB_vertex_buffer_object,
GL_ARB_vertex_program, GL_ARB_vertex_shader, GL_ARB_window_pos,
GL_ATI_draw_buffers, GL_ATI_envmap_bumpmap, GL_ATI_fragment_shader,
GL_ATI_meminfo, GL_ATI_separate_stencil, GL_ATI_texture_compression_3dc,
GL_ATI_texture_env_combine3, GL_ATI_texture_float, GL_EXT_abgr,
GL_EXT_bgra, GL_EXT_bindable_uniform, GL_EXT_blend_color,
GL_EXT_blend_equation_separate, GL_EXT_blend_func_separate,
GL_EXT_blend_minmax, GL_EXT_blend_subtract, GL_EXT_compiled_vertex_array,
GL_EXT_copy_texture, GL_EXT_draw_buffers2, GL_EXT_draw_range_elements,
GL_EXT_fog_coord, GL_EXT_framebuffer_blit, GL_EXT_framebuffer_multisample,
GL_EXT_framebuffer_object, GL_EXT_framebuffer_sRGB,
GL_EXT_gpu_program_parameters, GL_EXT_gpu_shader4,
GL_EXT_multi_draw_arrays, GL_EXT_packed_depth_stencil,
GL_EXT_packed_float, GL_EXT_packed_pixels, GL_EXT_point_parameters,
GL_EXT_rescale_normal, GL_EXT_secondary_color,
GL_EXT_separate_specular_color, GL_EXT_shadow_funcs, GL_EXT_stencil_wrap,
GL_EXT_subtexture, GL_EXT_texgen_reflection, GL_EXT_texture3D,
GL_EXT_texture_array, GL_EXT_texture_compression_latc,
GL_EXT_texture_compression_rgtc, GL_EXT_texture_compression_s3tc,
GL_EXT_texture_cube_map, GL_EXT_texture_edge_clamp,
GL_EXT_texture_env_add, GL_EXT_texture_env_combine,
GL_EXT_texture_env_dot3, GL_EXT_texture_filter_anisotropic,
GL_EXT_texture_integer, GL_EXT_texture_lod_bias,
GL_EXT_texture_mirror_clamp, GL_EXT_texture_object,
GL_EXT_texture_rectangle, GL_EXT_texture_sRGB,
GL_EXT_texture_shared_exponent, GL_EXT_transform_feedback,
GL_EXT_vertex_array, GL_KTX_buffer_region, GL_NV_blend_square,
GL_NV_conditional_render, GL_NV_copy_depth_to_color,
GL_NV_texgen_reflection, GL_SGIS_generate_mipmap,
GL_SGIS_texture_edge_clamp, GL_SGIS_texture_lod, GL_WIN_swap_hint,
WGL_EXT_swap_control
65 GLX Visuals
---- !!!
3)Try glxgears
Output should be:- (some RGB wheels moving in contact with edges)
306 frames in 5.0 seconds = 61.035 FPS
301 frames in 5.0 seconds = 60.186 FPS
302 frames in 5.0 seconds = 60.207 FPS
301 frames in 5.0 seconds = 60.200 FPS
301 frames in 5.0 seconds = 60.178 FPS
301 frames in 5.0 seconds = 60.188 FPS
4)Try fgl _glxgears
Output should be :-
Using GLX_SGIX_pbuffer
262 frames in 5.0 seconds = 52.400 FPS
298 frames in 5.0 seconds = 59.600 FPS
299 frames in 5.0 seconds = 59.800 FPS
286 frames in 5.0 seconds = 57.200 FPS
5)Try fglrxinfo
Output should be :-
[binnishah@redhat ~]$ fglrxinfo
display: :4.0 screen: 0
OpenGL vendor string: ATI Technologies Inc.
OpenGL renderer string: ATI Radeon HD 3200 Graphics
OpenGL version string: 2.1.8494 Release
*More ways to troubleshoot, is to analyse following:-
1)cat /var/log/Xorg.0.log | grep EE --> EE = error
2)cat /var/log/Xorg.0.log | grep EE --> WW = warning
3)dmesg | grep error
4)ccsm ( compiz config setting manager)
5)amdcccle
6)If you can't get xorg.conf (or dont find it in fresh fedora installation esp in Cambridge)
a)sudo yum install system-config-display
b)Menu - System - Administration - Display .Simply press ok ,so it will create in /etc/X11/xorg.conf later you can carry it from step 1 above
7)Open /etc/X11/xorg.conf and add in Section "Files"
ModulePath "/usr/lib/xorg/modules/extensions/fglrx"
ModulePath "/usr/lib/xorg/modules"
These is necessary to tell the server where to pick up the new driver. This is done by adding above lines in Files section
It’s important that this be the first ModulePath entry in the Files section. You can have more than one ModulePath in this section and they are all appended in order. This order is also the order searched for driver (and other) modules. So having this path first tells the server to look in our new driver directory first for the amd/ati driver.
Finally how my current xorg.conf looks like :-
# Xorg configuration created by system-config-display
Section "ServerLayout"
Identifier "single head configuration"
Screen 0 "aticonfig-Screen[0]-0" 0 0
InputDevice "Keyboard0" "CoreKeyboard"
EndSection
Section "Files"
ModulePath "/usr/lib/xorg/modules/extensions/fglrx"
ModulePath "/usr/lib/xorg/modules"
EndSection
Section "ServerFlags"
Option "AIGLX" "on"
EndSection
Section "InputDevice"
# keyboard added by rhpxl
Identifier "Keyboard0"
Driver "kbd"
Option "XkbModel" "pc105+inet"
Option "XkbLayout" "us"
EndSection
Section "Monitor"
Identifier "aticonfig-Monitor[0]-0"
Option "VendorName" "ATI Proprietary Driver"
Option "ModelName" "Generic Autodetecting Monitor"
Option "DPMS" "true"
EndSection
Section "Device"
Identifier "aticonfig-Device[0]-0"
Driver "fglrx"
BusID "PCI:1:5:0"
EndSection
Section "Screen"
Identifier "aticonfig-Screen[0]-0"
Device "aticonfig-Device[0]-0"
Monitor "aticonfig-Monitor[0]-0"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
Depth 24
EndSubSection
EndSection
Section "Extensions"
Option "Composite" "Enable"
EndSection
If you have any issues with ATI graphics card in linux,feel free to contact
What is formal & Actual parameter along with examples
Ok here we go ,
What are Formal Parameters ?
Ans:-
*Formal Parameter*
1)Consider y = f(x) // where x is independent & value of y is dependent on value returned by f.Here f(x) is formal parameter or argument to f
2)Formal parameters are place holders for values of "Actual parameter"
3)Formal parameters are declared/defined during function definition.
4)Examples :-
A)int f ( int x) --> x is formal paremter
B)int miles ( int km ,int mileage) --> km & mileage are formal parameter
5)In short in laymen language any fun. parameter that comes outside parenthesis is Formal parameter
*Actual parameter
1)In C prg. values that appears inside the parentheses are called "Actual Parameter"
2)Formal parameters must match in position,number & type
3)When a function call is made,a memory location is allocated for each formal parameter & a copy of corresponding actual parameter is kept in that memory location. All calculations involving the formal parameter use this memory location.
4)Actual parameters are always "Passed" & variables that are declared & passed as arguments to procedure by caller
5)Examples :-
A)#define MILEAGE 25 // Here MILEAGE is actual parameter
B)int miles(int gallons, int mileage) is Formal parameter
Consider following example:-
Problem:- Accepts a number of gallons as input from end user and calculates & displays the number of miles that can be traveled
#include
#define MILEAGE 25
int miles(int gallons,int mileage); // -->Both gallons & mileage are formal parameters
int main(void)
{
int f ; // --> f is actual parameter & f stores value in Gallons
printf("Enter number of Gallons of Gas : ");
scanf("%d",&f);
printf("\nYou will be able to travel %d miles from %d Gallons of Gasoline",miles(f,MILEAGE),f);/* here f & MILEAGE are actual parameters whose values are stored into gallons & mileage respectively which are formal parameters*/
return 0;
}
int miles(int gallons,int mileage)
{
return ( gallons * mileage); //Here both are formal parameters ie: gallons & mileage
}
*** Above example and some logic was taken from C by discovery by Foster & Foster